package com.yz.fanrenmianshi.mapper;

import com.yz.fanrenmianshi.model.entity.QuestionBank;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author K4s1ana
 * @description 针对表【question_bank(题库)】的数据库操作Mapper
 * @createDate 2025-06-18 14:54:59
 * @Entity com.yz.fanrenmianshi.model.entity.QuestionBank
 */
public interface QuestionBankMapper extends BaseMapper<QuestionBank> {

    /**
     * 根据题库ID列表批量查询题目数量
     * @param questionBankIds 题库ID列表
     * @return 返回题库ID和对应题目数量的映射
     */
    @Select({"<script>",
            "SELECT questionBankId, COUNT(*) as questionCount",
            "FROM question_bank_question",
            "WHERE questionBankId IN",
            "<foreach collection='questionBankIds' item='id' open='(' separator=',' close=')'>#{id}</foreach>",
            "GROUP BY questionBankId",
            "</script>"})
    List<Map<String, Object>> getQuestionCountByBankIds(@Param("questionBankIds") List<Long> questionBankIds);

}




